package com.geeka.d12.tcp;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

public class TcpClientDemo1 {
    public static void main(String[] args) {
        try {
            //1, 建立连接
            Socket socket = new Socket("127.0.0.1", 9999);
            OutputStream ops = socket.getOutputStream();
            PrintStream ps = new PrintStream(ops);
            ps.println("你好,我的TCP客户端");
            ps.flush();

            socket.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
